package com.by.demo;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class C3p0Demo {
    public static void main(String[] args) throws Exception {
        Connection conn=null;
        PreparedStatement pst=null;
        ResultSet rs=null;
        DataSource dataSource=new ComboPooledDataSource();
             conn = dataSource.getConnection();
            //构建sql语句操作
            String sql="select * from student";
            pst = conn.prepareStatement(sql);
             rs = pst.executeQuery();

            while (rs.next()){
                System.out.println(rs.getInt("sid")+"  "+rs.getString("name")
                        +"  "+rs.getInt("age")+"  "+rs.getDate("birthday"));
            }

            conn.close();
            pst.close();
            rs.close();

    }



}
